package ar.fiuba.logger;

import java.util.HashMap;
import java.util.Map;

/**
 * The Class FiubaLogger.
 * 
 * This class is used to access and create the loggers.
 */
public class FiubaLogger {

  /** The Constant loggers. */
  static final Map<String, Logger> loggers = new HashMap<String, Logger>();

  /**
   * Creates a logger with the given name and the default configuration rules.
   * 
   * @param name the name
   */
  static public void create(String name) {
    Logger logger = LoggerBuilder.build(name);

    loggers.put(name, logger);
  }

  /**
   * Creates a logger with the given name, using a config object.
   * 
   * @param name the name
   * @param config the config object
   */
  static public void create(String name, LogConfig config) {
    Logger logger = LoggerBuilder.build(name, config);

    loggers.put(name, logger);
  }

  /**
   * Creates a logger with the given name, using a Properties config file.
   * 
   * @param name the name
   * @param filename the filename
   */
  static public void createFromProperties(String name, String filename) {
    Logger logger = LoggerBuilder.buildFromProperties(name, filename);

    loggers.put(name, logger);
  }

  /**
   * Creates a logger with the given name, using an XML config file.
   * 
   * @param name the name
   * @param filename the filename
   */
  static public void createFromXML(String name, String filename) {
    Logger logger = LoggerBuilder.buildFromXML(name, filename);

    loggers.put(name, logger);
  }

  /**
   * Gets the logger.
   * 
   * @param name the name
   * @return the logger
   */
  static public Logger getLogger(String name) {
    return loggers.get(name);
  }
}
